ChatApp
Class ChatClientServant

java.lang.Object
  |
  +--org.omg.CORBA.portable.ObjectImpl
        |
        +--org.omg.CORBA.DynamicImplementation
              |
              +--ChatApp._ChatClientImplBase
                    |
                    +--ChatApp.ChatClientServant

public class ChatClientServant
extends _ChatClientImplBase

ChatClientServant is the main object of a ChatClient in the secured CHat Application. This object is in charge of the registration and messaging of the client to the server and other registered client All the encryption and decryption is done by this class leaving the gui to handle only the communication with the CORBA naming service. The Methods marked as remote methods are invoked by the remote ChatRegistryServant. Other methods are invoked by the application gui.

See Also:
Serialized Form

Constructor Summary
ChatClientServant()
          Empty constructor when no gui is used
ChatClientServant(MyChatApp app)
          Cunstructs a ChatClientServant for a specific gui.
 
Method Summary
 void ackRegister(short ackType)
          Remote methode for acknowledging the registration.
 void broadcastMessage(java.lang.String message, java.lang.String clientID, ChatRegistry ref)
          Broadcast a message to all other registered clients by encrypting the original message with the server's session key and remotely invoke the broadcast method on the remote ChatRegistry object
 void clientAdded(java.lang.String clientID)
          Remote method.
 void clientRemoved(java.lang.String clientID)
          Remote Method.
 void printMessage(byte[] Message, java.lang.String sourceID)
          Remote method.
 void printPrivateMessage(byte[] Message, java.lang.String SourceID)
          Remote method.
 void registerToServer(java.lang.String clientID, ChatRegistry ref)
          Register this client to the server by encrypting his client ID and remotely invoke the server's register method.
 void sendPrivateMessage(java.lang.String message, java.lang.String sourceID, java.lang.String destID, ChatRegistry ref)
          Send a private message to another registered client by encrypting the message, the sender's ID and the receiver's ID with the server's PKCS public key (so other registered users can't decrypt) and remotely invoke the sendPrivateMessage on the ChatRegistry remote object
 void unregisterFromServer(java.lang.String clientID, ChatRegistry ref)
          UnRegister this client to the server by encrypting his client ID and remotely invoke the server's unregister method.
 
Methods inherited from class ChatApp._ChatClientImplBase
_ids, invoke
 
Methods inherited from class org.omg.CORBA.portable.ObjectImpl
_create_request, _create_request, _duplicate, _get_delegate, _get_domain_managers, _get_interface_def, _get_policy, _hash, _invoke, _is_a, _is_equivalent, _is_local, _non_existent, _orb, _release, _releaseReply, _request, _request, _servant_postinvoke, _servant_preinvoke, _set_delegate, _set_policy_override, equals, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChatClientServant

public ChatClientServant()
Empty constructor when no gui is used

ChatClientServant

public ChatClientServant(MyChatApp app)
Cunstructs a ChatClientServant for a specific gui.
Parameters:
app - The application gui of the ChatClient.
Method Detail

ackRegister

public void ackRegister(short ackType)
Remote methode for acknowledging the registration. This method is remotely called by the server after the client's attempt to register to the server.
Parameters:
ackType - acknowledge type. For future implementations. Not used in this version.

printMessage

public void printMessage(byte[] Message,
                         java.lang.String sourceID)
Remote method. Prints a broadcasted message from another registered client to the application gui
Parameters:
encMessage - The encrypted message, encrypted by the server's session key
sourceID - the sender's ID

printPrivateMessage

public void printPrivateMessage(byte[] Message,
                                java.lang.String SourceID)
Remote method. Prints a private message from another registered client to the application gui
Parameters:
encMessage - The encrypted message, encrypted with the client public PKCS key
encSourceID - The encrypted sender's ID, encrypted by the client public PKCS key

clientAdded

public void clientAdded(java.lang.String clientID)
Remote method. Inform the gui about a new client on the ChatServer

clientRemoved

public void clientRemoved(java.lang.String clientID)
Remote Method. Informs the gui about a removed client from the ChatServer

registerToServer

public void registerToServer(java.lang.String clientID,
                             ChatRegistry ref)
Register this client to the server by encrypting his client ID and remotely invoke the server's register method.
Parameters:
clientID - The unencrypted registering client ID
ref - a remote object represents the ChatRegistry

unregisterFromServer

public void unregisterFromServer(java.lang.String clientID,
                                 ChatRegistry ref)
UnRegister this client to the server by encrypting his client ID and remotely invoke the server's unregister method.
Parameters:
clientID - The unencrypted unregistering client ID
ref - a remote object represents the ChatRegistry

broadcastMessage

public void broadcastMessage(java.lang.String message,
                             java.lang.String clientID,
                             ChatRegistry ref)
Broadcast a message to all other registered clients by encrypting the original message with the server's session key and remotely invoke the broadcast method on the remote ChatRegistry object
Parameters:
message - The original, unencrypted message
clientID - The sender's ID
ref - a remote object represents the ChatRegistry

sendPrivateMessage

public void sendPrivateMessage(java.lang.String message,
                               java.lang.String sourceID,
                               java.lang.String destID,
                               ChatRegistry ref)
Send a private message to another registered client by encrypting the message, the sender's ID and the receiver's ID with the server's PKCS public key (so other registered users can't decrypt) and remotely invoke the sendPrivateMessage on the ChatRegistry remote object
Parameters:
message - The original unencrypted message
sourceID - The sender's unencrypted ID
destID - The receiver's unencrypted ID
ref - a remote object represents the ChatRegistry